package cn.kgc.house.service;

import cn.kgc.house.common.CrowdFundingUtils;
import cn.kgc.house.mapper.OrderMapper;

import cn.kgc.house.pojos.Order;
import cn.kgc.house.pojos.OrderExample;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.aspectj.weaver.ast.Or;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class OrderServiceImpl implements  OrderService {
    @Resource
    OrderMapper orderMapper;
    /*查询分页*/
    @Override
    public PageInfo<Order> queryForKeywordSearchOrder(Integer pageNum, Integer pageSize, String buildName) {
      PageHelper.startPage(pageNum,pageSize);
if (CrowdFundingUtils.stringEffective(buildName)){
    List<Order> list=orderMapper.select(buildName);
PageInfo<Order> pageInfo=new PageInfo<>(list);
return  pageInfo;

}else {

    List<Order> list=orderMapper.select(null);
    PageInfo<Order> pageInfo=new PageInfo<>(list);
    return  pageInfo;

}

    }

    @Override
    public void insertOrder(Order order) {
orderMapper.insert(order);

    }

    @Override
    public Order selectByIdOrder(Integer id) {
        return orderMapper.selectByPrimaryKey(id);
    }

    @Override
    public void updateOrder(Order order) {
orderMapper.updateByPrimaryKeySelective(order);
    }
}
